/*
 * author  : Ramesh Ramaswamy
 * email   : ramesh.ramaswamy@hotmail.com
 * created : 21 sepetember 2014
 *
 * info    : microcontroller needs a filesystem based on datastructure
 *         : which is fast and works with ROM and RAM storage.
 *
 */

#include <stdio.h>
#include <efs_core.h>
#include <efs_ram.h>
#include <unistd.h>

int main ( int argc, char *argv[] ) {
	int option, opt_g = 0, opt_e = 0;
	if ( argc < 4 ) {
syntax_error:
		printf ( "syntax : efs <options>\n" );
		printf ( "\texample:\n" );
		printf ( "\t\tefs -g <path> <filename>\n" );
		printf ( "\t\tefs -e <filename> <path>\n" );
		return 1;
	}
	opterr = 0;
	while ((option = getopt ( argc, argv, "ge" )) != -1 ) {
		switch ( option ) {
			case 'g':
				if (!opt_g) {
					printf ( "creating efs from path %s to efs file %s\n", argv [ 2 ], argv [ 3 ] );
					opt_g = 1;
				} else {
					fprintf ( stderr, "repeated syntax usage, ignoring\n " );
				}
				break;
			case 'e':
				if (!opt_e ) {
					printf ( "extracting directory from %s efs file to path %s\n", argv [ 2 ], argv [ 3 ] );
					opt_e = 1;
				} else {
					fprintf ( stderr, "repeated syntax usage, ignoring\n " );
				}
				break;
			case '?':
				goto syntax_error;
				break;
			default:
				goto syntax_error;
				break;
		}
	}
	return 0;
}
